import {makeAutoObservable} from "mobx";
import {goodsTableColumnNames} from "../components/GoodsTable";
import {persistToLocalStorage} from "../utils/MboxUtils";

type ColumnFields = typeof goodsTableColumnNames

export  interface RememberedColumnCache {
    goods?: ColumnFields
    marketOrder?: ColumnFields
    marketSaleDocument?:ColumnFields
    procurement?:ColumnFields
    procurementReceipt?:ColumnFields
}

class TableColumnSelectStore {

    cache: RememberedColumnCache = {}

    constructor() {
        makeAutoObservable(this)
        persistToLocalStorage("tableColumnSelectCache", data => {
            this.cache = data
        }, () => {
            return this.cache
        })
    }

}

export default new TableColumnSelectStore()